package pers.gxm.observer;

public class IncrementalNumberGenerator extends NumberGenerator{
    public static void main(String[] args) {
        IncrementalNumberGenerator ge = new IncrementalNumberGenerator(10, 50, 5);
        ge.addObserver(new DigitObserver());
        ge.addObserver(new GraphObserver());
        ge.execute();
    }
    private int number;
    private int begin;
    private int end;
    private int step;

    public IncrementalNumberGenerator(int begin ,int end,int step){
        this.begin = begin;
        this.end = end;
        this.step = step;
    }
    @Override
    public int getNumber() {
        return this.number;
    }

    @Override
    public void execute() {
        for(int i = begin;i < end;i += step){
            this.number = i;
            notifyObservers();
        }
    }
}
